
package io.xiyou.order.service.support;

import io.xiyou.order.dao.mapper.LocalCancelLogMapper;
import io.xiyou.order.dao.mapper.LocalConfirmLogMapper;
import io.xiyou.order.dao.mapper.LocalTryLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Hmily事务业务处理类
 */
@Slf4j
@Service
public class HmilySupport {

    @Autowired
    private LocalCancelLogMapper localCancelLogMapper;
    @Autowired
    private LocalConfirmLogMapper localConfirmLogMapper;
    @Autowired
    private LocalTryLogMapper localTryLogMapper;

    /**
     * 查询分支事务try是否已执行
     *
     * @param txNo
     * @return
     */
    public int isExistTry(String txNo) {
        return localTryLogMapper.isExistTry(txNo);
    }

    /**
     * 查询分支事务confirm是否已执行
     *
     * @param txNo
     * @return
     */
    public int isExistConfirm(String txNo) {
        return localConfirmLogMapper.isExistConfirm(txNo);
    }

    /**
     * 查询分支事务cancel是否已执行
     *
     * @param txNo
     * @return
     */
    public int isExistCancel(String txNo) {
        return localCancelLogMapper.isExistCancel(txNo);
    }

    /**
     * 增加某分支事务try执行记录
     *
     * @param txNo
     * @return
     */
    public int addTry(String txNo) {
        return localTryLogMapper.addTry(txNo);
    }

    public int addConfirm(String txNo) {
        return localConfirmLogMapper.addConfirm(txNo);
    }

    public int addCancel(String txNo) {
        return localCancelLogMapper.addCancel(txNo);
    }

}
